#include<stdio.h>
#include<stulib.h>
/*定义结构体和结构体指针的名字，以便后续简便运算*/
typedef struct listnode{
	int data;
	struct listnode* nextptr;
}LISTNODE;
typedef LISTNODE *LISTNODEPTR;
/*创建一个带有空节点的链表头*/
void createListHead (LISTNODEPTR * headPtrPtr){
	*headPtrPtr = malloc(sizeof(LISTNODE));
	if ((*headPtrPtr) != NULL){
		(*headPtrPtr)->nextptr = NULL;
	}
}
int main(){
	LISTNODEPTR headPtr = NULL;
	createListHead(&headPtr);
	if (headPtr == NULL){
		printf("List not ctreated. No memory avaliable.\n\n");
		exit(-1);
	}
}
void insertEnd1 (LISTNODEPTR , int newdata ){
	LISTNODEPTR newPtr, previousPtr, currentPtr;
	/*动态分配新节点，将新值存入*/
	newPtr = malloc(sizeof(LISTNODE));
	if (newPtr != NULL){
		newPtr->data = newdata;
		newPtr->nextPtr = NULL;
		/*寻找尾节点*/
		previousPtr = sPtr ;
		currentPtr = sPtr->nextPtr;
		while (currentPtr != NULL){
			previousPtr = currentPtr;
			currentPtr = currentPtr->nextPtr;
		}
		previousPtr->nextPtr = newPtr;   /*在尾节点后链接新节点*/
	}
	else
		printf("Nothing is insert in the end.\n");
}
